<?php
namespace Home\Controller;
use Think\Controller;
class SearchController extends HomeController
{
    public function index(){
//        dump($_GET);
        if(IS_GET){
            $q1 = empty($_GET['q1'])?'':$_GET['q1'];
            $q1 = "'%$q1%'";
            $goods = M("goods");
            $goodslist = $goods
                ->alias("g")
                ->join("shopping_goodsimg i on g.id = i.goods_id")
                ->where("i.is_main=1 and g.is_show=1 AND g.name like $q1")
                ->field(array("g.id", "g.name", "g.price", "g.num", "g.sales_num", "g.is_show", "g.is_new", "g.is_hot","g.is_integral", "g.is_coupon", "g.special_id", "g.seckill_id", "g.integral_price","g.category_id", "i.img"))
                ->select();

//            dump($goodslist);die;
            $this->assign('goodslist',$goodslist);

            $this->display('Search/index');
        }else{
            E('错误');
        }
    }
}